app.controller('shopLocatedCtrl',['$scope','utilService','shopLocatedService','$modal','$stateParams','toaster','$state', '$interval',
    function($scope,utilService,shopLocatedService,$modal,$stateParams,toaster,$state,$interval) {
        //定义交互对象
        $scope.shopLocatedBO = {};
        //渲染对象
        $scope.tableList = [];

        //初始化调用函数
        $scope.init = function(){
            //初始化调用查询所有方法
            $scope.findAllShopLocated();
        }

        //查询所有方法
        $scope.findAllShopLocated=function(){
            utilService.queryForPagingList($scope,{
                url:$scope.app.domain + 'shop/located',
                params: $scope.shopLocatedBO
            }).then(function(result){
                if(result!=null && result.list!=null){
                    for(var i =0;i<result.list.length;i++){
                        var itme = result.list[i];
                        var s = itme['createdTime'].replace(/-/g,"/");
                        var dateInterval = new Date(s);
                        var prescription = (new Date().getTime())-dateInterval.getTime();
                        itme['prescription'] = prescription/1000;
                    }
                }
            });
        };

       var timer = $interval( function(){
            $scope.findAllShopLocated();
        }, 30000);
        $scope.$on("$destroy", function() {
            $interval.cancel(timer);
        });
    }
]);